package com.jiyun.service.impl;

import com.jiyun.pojo.Shoppingcart;
import com.jiyun.mapper.ShoppingcartMapper;
import com.jiyun.service.IShoppingcartService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 购物车 服务实现类
 * </p>
 *
 * @author author
 * @since 2024-12-19
 */
@Service
public class ShoppingcartServiceImpl extends ServiceImpl<ShoppingcartMapper, Shoppingcart> implements IShoppingcartService {

    @Override
    public List<Shoppingcart> shoppingcartselectbyid(String[] id) {
        List<Shoppingcart> shoppingcartList = new ArrayList<>(); // 创建集合用于存储结果
        for (String s : id) {
            Shoppingcart cart = baseMapper.shoppingcartselectbyid(s); // 查询单个购物车
            if (cart != null) { // 确保查询结果不为空
                shoppingcartList.add(cart); // 将结果添加到集合中
            }
        }
        return shoppingcartList; // 返回结果集合
    }
}
